<%@ page import="cn.java79.quiz.entity.User" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="cn.java79.quiz.util.MybatisUtil" %>
<%@ page import="cn.java79.quiz.dao.UserMapper" %>
<%@ page import="cn.java79.quiz.service.UserService" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2022/8/22
  Time: 17:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
 <%
     //request.getParameterValues()
     //request.getParameter("")
     request.setCharacterEncoding("utf-8");//设置字符集
     String logname=request.getParameter("loginname");
     String realname=request.getParameter("realname");
     String phone=request.getParameter("phone");
     String email=request.getParameter("email");
     String pass=request.getParameter("pass");
     int score=Integer.parseInt(request.getParameter("score"));
     User user=new User(logname,realname,phone,email,pass);
     user.setScore(score);
     String ip=request.getRemoteHost();//获得ip
     out.print("<h1>ip是："+ip+"</h1>");
     out.print("<h1>登录名是："+logname+"</h1>");
     out.print("<h1>姓名是："+realname+"</h1>");
     int save= UserService.ME.save(user);
//     SqlSession s= MybatisUtil.get();
//     UserMapper mapper = s.getMapper(UserMapper.class);
//     int save = mapper.save(user);
//     MybatisUtil.close(s);
     if(save>0)
     {
         out.print("增加成功");
         out.print("<a href='users.jsp'>查看</a>");
     }
     else{
         out.print("增加失败");
         out.print("<a href='javascript:history.back()'>返回</a>");
     }

 %>
</body>
</html>
